<template>
    <div class="sign-all" :style="{minHeight: minH + 'px'}">
      <div>
        <p class="title">请选择您的课程需求</p>
        <p class="title-one">您将收到相关开课通知</p>
        <div class="main-box">
          <span class="main-box-one">推荐大咖（非必填）</span>
          <textarea class="main-text" v-model="searchmsg.recommend_teacher" maxlength="200" onchange="this.value=this.value.substring(0, 200)" onkeydown="this.value=this.value.substring(0, 200)" onkeyup="this.value=this.value.substring(0, 200)"></textarea>
          <span class="main-two">{{allLen}}/200</span>
        </div>
        <div class="main-box" style="margin-top: 20px;">
          <span class="main-box-one">推荐课题（非必填）</span>
          <textarea class="main-text" v-model="searchmsg.recommend_course" maxlength="200" onchange="this.value=this.value.substring(0, 200)" onkeydown="this.value=this.value.substring(0, 200)" onkeyup="this.value=this.value.substring(0, 200)"></textarea>
          <span class="main-two">{{allLen1}}/200</span>
        </div>
        <p class="mbtn" @click="select">提交我的需求</p>
        <div class="tips">侃侃电商学院</div>
        <div class="feedback" @click="gofeed">问题反馈</div>
      </div>
      <tab-ber :current="2"></tab-ber>
    </div>
</template>

<script>
import TabBer from '../public/tabber'
import msgbox from '@/common/msgbox.js'
import { Toast } from 'mint-ui'

export default {
  components: {TabBer},
  name: 'index',
  data () {
    return {
      minH: '',
      msg: '',
      isshow: '',
      searchmsg: {
        recommend_teacher: '',
        recommend_course: ''
      },
      allLen: 0,
      allLen1: 0
    }
  },
  mounted () {
    this.minH = window.screen.height
  },
  watch: {
    searchmsg: {
      handler (val, oldVal) {
        this.allLen = val.recommend_teacher.length
        this.allLen1 = val.recommend_course.length
      },
      deep: true
    }
  },
  methods: {
    gofeed () {
      this.$router.push('/users/feedback')
    },
    select () {
      let that = this
      this.$g.ajax({
        path: 'Courseneeds/add',
        method: 'post',
        data: that.searchmsg,
        cbSuccess: function () {
          Toast({
            message: '提交成功',
            position: 'bottom',
            duration: 1000
          })
        },
        cbError: function (data) {
          let msg = msgbox.get(data.msg)
          Toast({
            message: msg,
            position: 'bottom',
            duration: 1000
          })
        }
      })
    }
  }
}
</script>

<style scoped lang="scss">
  .tips{
    text-align: center;
    padding-top: 20px;
    font-size: 22px;
    font-weight: bold;
    color: #d4d8d8;
    background: rgba(244,244,244,0.8);
  }
  .feedback{
    text-align: right;
    font-size: 12px;
    padding-right: 14px;
    color: #ababab;
    background: rgba(244,244,244,0.8);
    padding-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
  }
  .sign-all{
    width: 100%;
    background: rgba(244,244,244,0.8);
    .title{
      font-size: 18px;
      text-align: center;
      padding-top: 20px;
    }
    .title-one{
      text-align: center;
      line-height: 30px;
      font-size: 12px;
      color: #999999;
    }
    .main-box{
      width: 94%;
      margin-left: 3%;
      height: 150px;
      background: white;
      border: 1px solid #ededed;
      border-radius: 5px;
      .main-box-one{
        display: inline-block;
        width: 100%;
        line-height: 40px;
        font-size: 14px;
        color: #999999;
        padding-left: 10px;
        box-sizing: border-box;
        border-bottom: 1px solid #ededed;
      }
      .main-text{
        width: 94%;
        margin-left: 3%;
        box-sizing: border-box;
        display: inline-block;
        margin-top: 10px;
        resize: none;
        height: 60px;
        border: none;
        color: #666;
      }
      .main-two{
        text-align: right;
        color: #666;
        display: inline-block;
        width: 97%;
        font-size: 18px;
      }
    }
    .mbtn{
      width: 94%;
      line-height: 40px;
      border-radius: 5px;
      float: left;
      margin-left: 3%;
      margin-bottom: 20px;
      color: white;
      background: #0a51cc;
      text-align: center;
      margin-top: 40px;
    }
  }
</style>
